package enums;

import org.apache.commons.lang3.StringUtils;

/**
 * @ClassName CommonErrorEnum
 * @Deacription TODO
 * @Author jianhua.hong
 * @Date 2019/11/13 10:06
 * @Version 1.0
 **/
public enum CommonErrorEnum {

	NOT_FOUND_ERROR("1001000", "NOT_FOUND_ERROR", "错误码未定义"),

	;

	private String code;

	private String message;

	private String messageCN;

	private CommonErrorEnum(String code, String message, String messageCN) {
		this.code = code;
		this.message = message;
		this.messageCN = messageCN;
	}

	public String getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	public String getMessageCN() {
		return messageCN;
	}

	public static CommonErrorEnum getErrorEnum(String code) {
		if (StringUtils.isBlank(code)) {
			return NOT_FOUND_ERROR;
		}
		for (CommonErrorEnum e : CommonErrorEnum.values()) {
			if (e.getCode().equals(code)) {
				return e;
			}
		}
		return NOT_FOUND_ERROR;
	}

}
